# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :configHttp.py
# @Time      :2022/7/12 22:56
# @Author    :jiaxuesong


import requests


#定义一个类，封装调用方法
class ConfigHttp(object):
    #定义一个初始化方法，接收参数
    def __init__(self, m, u, v):
        self.method = m
        self.url = u
        self.value = v

    #根据传入的method判断是get或post请求
    def run(self):
        if self.method == 'get':
            re = self.__get()
            return re
        elif self.method == 'post':
            re = self.__post()
            return re

    #定义get私有方法
    def __get(self):
        re = requests.get(url=self.url, params=self.value)
        return re

    #定义post私有方法
    def __post(self):
        re = requests.post(url=self.url, data=self.value)
        return re





